/**
 * Created by jiaoyumin on 2017/9/29.
 */
import * as types from './mutation-types'
import * as api from '../api';
import axios from "axios";

/**
 * 旅行社actions start
 */
export const loginGetUserInfo = async ({commit, dispatch}, {flag}) => {
  flag ?
    commit(types.SET_USERINFO, await api.taLogin())
    : commit(types.SET_USERINFO, await api.govLogin());
    if(flag){
      await dispatch('getAgencyInfo').then(res => {},error => {});
    }
}

export const getSupportInfo = async ({commit}) => {
  commit(types.SUPPORT_INFO, await api.getSupportInfo());
}

export const getProcess = async ({commit}) => {
  commit(types.PROCESS, await api.getProcess());
}

export const getSysInfo = async ({commit,dispatch},flag) => {
  commit(types.SYS_INFO, await api.getSysInfo(flag));
}

export const getAgencyInfo = async ({commit}) => {
  commit(types.AGENCY_INFO, await api.getAgencyInfo());
}

export const setWljdArray = ({commit}, data) => {
  commit(types.WLJD_ARRAY, data);
}

export const setZzjdArray = ({commit}, data) => {
  commit(types.ZZJD_ARRAY, data);
}

export const setZzcjArray = ({commit}, data) => {
  commit(types.ZZCJ_ARRAY, data);
}

export const getReportDetail = async ({commit}) => {
  commit(types.REPORT_DETAIL, await api.getReportDetail());
}

export const getAnyLisis = async ({commit,state},{year}) => {
  commit(types.ANY_LISIS, await api.getAnyLisis(year));
}

export const getReportDetailForId = async ({commit},id) => {
  commit(types.REPORT_DETAIL,await api.getReportDataForId(id));
}

export const getReportHistory = async ({commit},params)=>{
  commit(types.REPORT_LIST,await api.getReportHistorys(params));
}
/**
 * 旅行社actions  end
 */

/**
 * 旅游局actions start
 */
export const getTourismProcess = async ({commit}) => {
  commit(types.TOURISM_PROCESS,await api.getTourismProcess());
}


export const getAgencylist = async ({commit},params) => {
  commit(types.AGENCYLIST,await api.getAgencylist(params))
}

export const getStopedAgencyList = async ({commit},params) => {
  commit(types.STOPED_AGENCYLIST,await api.getStopedAgencyList(params));
}

export const getProcessList = async ({commit},params) => {
  commit(types.PROCESS_LIST,await api.getProcessList(params));
}

export const getGovReportDetailForId = async ({commit},code) => {
  commit(types.REPORT_DETAIL,await api.getGovReportDetail(code));
}

export const setAuditReportGroupLevel = async({commit},level) => {
  commit(types.GOV_REPORT_GROUP_LEVEL,level)
}